require "yaml"
require "deployerOptions.rb"
require "DeployerStrategies.rb"

class YMLTester

	def doTest()
		puts "hello"

		test_obj = ["dogs", "cats", "badgers"]

		yaml_obj = YAML::dump( test_obj )

		%x[dir ]

		puts yaml_obj

		ruby_obj = YAML::load( yaml_obj )

		puts (ruby_obj == test_obj)
	end
end
class DPLProjectConfig
	attr_accessor	:name, :acronym, :type, :root, :trunk_dir, :branch_dir, :tag_dir, :latest_tag, :revision_tag, :major_version, :minor_version
	
	def initialize()
		
	end
	
	
end

class Deployer
	
	def load_file(filename)
		return YAML::load(File.open(filename))
	end
	
	def load_projects()

		projects_info =  self.load_file("project.yml")
		@projects = []
		projects_info.each do |p|
			project = p[1]
			project.name = p[0]
			@projects << project
		end
	end
	
	def project_info()
		puts "Project DEPLOYER, by Leonardo Luarte G. (leonardo@luarte.net)"
		puts "For additional info use deployer -h."
	end
	def process_options()
		strategy = nil
		if @options[:list] then strategy = ListProjectsStrategy.new() end
		if @options[:run] then strategy = CommitProjectStrategy.new() end
		if not strategy.nil? then strategy.execute(@projects,@options) end
	end
	def start()
		project_info()
		dplopt = DeployerOptions.new()
		load_projects()
		@options = dplopt.options
		process_options()
		
		#list_projects()
	end
	
end

if not ARGV.nil? then 
	Deployer.new().start()
end